/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Modif_Reg_Socio.java
 *
 * Created on 05/01/2012, 02:04:39 PM
 */
package Vista;

import DAO_Modelo.dto.SocioPk;
import DAO_Modelo.exceptions.SocioDaoException;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author jose,digberht
 */
public class Modif_Reg_Socio extends javax.swing.JFrame {

    /** Creacion de un nuevo formulario Modif_Reg_Socio */
    private static int fila;
    
    
    public Modif_Reg_Socio(int d) {
        this.fila=d;
        initComponents();
        jLabel_nombreSocio.setText("Nombre : "+Sigele.sociodtoLista[fila].getNombre()+" "+Sigele.sociodtoLista[fila].getApellidos());
        jLabel_CodSocio.setText("Codigo : "+Sigele.sociodtoLista[fila].getCodigoSocio());
        jText_DUsuario_ComunZona.setText(Sigele.sociodtoLista[fila].getComunidadZona());
        jText_DUsuario_CorreoElect.setText(Sigele.sociodtoLista[fila].getCorreoElectronico());
        jText_DUsuario_Departam.setText(Sigele.sociodtoLista[fila].getDepartamento());
        jText_DUsuario_Direccion.setText(Sigele.sociodtoLista[fila].getDireccion());
        jText_DUsuario_Provincia.setText(Sigele.sociodtoLista[fila].getProvincia());
        jText_DUsuario_RefUbicacion.setText(Sigele.sociodtoLista[fila].getReferenciaUbic());
        jText_DUsuario_Telefono.setText(Sigele.sociodtoLista[fila].getTelefono());
        jComboBox2.setSelectedItem(Sigele.sociodtoLista[fila].getDistrito());
        
        jText_DUsuario_Departam.setEditable(false);
        jText_DUsuario_Provincia.setEditable(false);
        jText_DUsuario_ComunZona.setEditable(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel4 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jText_DUsuario_Direccion = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jText_DUsuario_RefUbicacion = new javax.swing.JTextField();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jText_DUsuario_Departam = new javax.swing.JTextField();
        jText_DUsuario_Provincia = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jText_DUsuario_Telefono = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jText_DUsuario_CorreoElect = new javax.swing.JTextField();
        jButton_DUsuario_Cerrar = new javax.swing.JButton();
        jButton_DUsuario_Grabar = new javax.swing.JButton();
        jButton_DUsuario_Imprimir = new javax.swing.JButton();
        jText_DUsuario_ComunZona = new javax.swing.JTextField();
        jLabel_nombreSocio = new javax.swing.JLabel();
        jLabel_CodSocio = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos de Usuario"));

        jLabel4.setText("Direccion:");

        jText_DUsuario_Direccion.setText("jTextField2");

        jLabel6.setText("Distrito:");

        jLabel7.setText("Comunidad/Zona:");

        jLabel8.setText("Referencia Ubicac.:");

        jText_DUsuario_RefUbicacion.setText("jTextField3");

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(Sigele.Distritos));

        jLabel9.setText("Provincia:");

        jLabel10.setText("Departamento:");

        jText_DUsuario_Departam.setText("jTextField5");

        jText_DUsuario_Provincia.setText("jTextField6");

        jLabel12.setText("Telefono:");

        jText_DUsuario_Telefono.setText("jTextField7");

        jLabel13.setText("Correo Electronico:");

        jText_DUsuario_CorreoElect.setText("jTextField8");

        jButton_DUsuario_Cerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/salisr.JPG"))); // NOI18N
        jButton_DUsuario_Cerrar.setText("Cerrar");
        jButton_DUsuario_Cerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_DUsuario_CerrarActionPerformed(evt);
            }
        });

        jButton_DUsuario_Grabar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/guardar.JPG"))); // NOI18N
        jButton_DUsuario_Grabar.setText("Grabar");
        jButton_DUsuario_Grabar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_DUsuario_GrabarActionPerformed(evt);
            }
        });

        jButton_DUsuario_Imprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/imprimir.JPG"))); // NOI18N
        jButton_DUsuario_Imprimir.setText("Imprimir");

        jText_DUsuario_ComunZona.setText("jTextField1");

        jLabel_nombreSocio.setText("jLabel1");

        jLabel_CodSocio.setText("jLabel2");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel_nombreSocio, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel_CodSocio, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE))
                    .addComponent(jLabel4)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8)
                            .addComponent(jLabel7)
                            .addComponent(jLabel6))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jText_DUsuario_RefUbicacion, javax.swing.GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)
                            .addComponent(jText_DUsuario_Direccion, javax.swing.GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jComboBox2, 0, 119, Short.MAX_VALUE)
                                    .addComponent(jText_DUsuario_ComunZona, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel9))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                        .addGap(8, 8, 8)
                                        .addComponent(jLabel10)))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jText_DUsuario_Provincia)
                                    .addComponent(jText_DUsuario_Departam, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(jText_DUsuario_Telefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jText_DUsuario_CorreoElect, javax.swing.GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGap(37, 37, 37)
                                .addComponent(jButton_DUsuario_Imprimir, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton_DUsuario_Grabar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton_DUsuario_Cerrar, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE))))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 389, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel13))
                .addGap(31, 31, 31))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_nombreSocio)
                    .addComponent(jLabel_CodSocio))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jText_DUsuario_Direccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(31, 31, 31)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel9)
                        .addComponent(jText_DUsuario_Provincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel6))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jLabel10)
                    .addComponent(jText_DUsuario_Departam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jText_DUsuario_ComunZona, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jText_DUsuario_RefUbicacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jText_DUsuario_Telefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addComponent(jText_DUsuario_CorreoElect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(27, 27, 27)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton_DUsuario_Cerrar)
                            .addComponent(jButton_DUsuario_Imprimir)
                            .addComponent(jButton_DUsuario_Grabar)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jLabel13)))
                .addGap(21, 21, 21))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(13, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(22, 22, 22))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
/** 
	 * Funcion de evento del boton de Cierra  el formulario actual activo
	 */
private void jButton_DUsuario_CerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_DUsuario_CerrarActionPerformed
// TODO add your handling code here:
    this.dispose();
}//GEN-LAST:event_jButton_DUsuario_CerrarActionPerformed
/** 
	 * Funcion de evento del boton de grabar el cual actualiza los campos modificado en la base de Datos
	 */
private void jButton_DUsuario_GrabarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_DUsuario_GrabarActionPerformed
// TODO add your handling code here:
    Sigele.sociodtoLista[fila].setDireccion(jText_DUsuario_Direccion.getText());
    Sigele.sociodtoLista[fila].setDistrito(jComboBox2.getSelectedItem().toString());
    Sigele.sociodtoLista[fila].setReferenciaUbic(jText_DUsuario_RefUbicacion.getText());
    Sigele.sociodtoLista[fila].setTelefono(jText_DUsuario_Telefono.getText());
    Sigele.sociodtoLista[fila].setCorreoElectronico(jText_DUsuario_CorreoElect.getText());
        try {
            Sigele.socioDao.update(new SocioPk(Sigele.sociodtoLista[fila].getCodigoSocio()), Sigele.sociodtoLista[fila]);
            JOptionPane.showMessageDialog(null,"Datos actualizados correctamente!");
        } catch (SocioDaoException ex) {
            Logger.getLogger(Modif_Reg_Socio.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_jButton_DUsuario_GrabarActionPerformed


     /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Modif_Reg_Socio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Modif_Reg_Socio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Modif_Reg_Socio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Modif_Reg_Socio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Modif_Reg_Socio(fila).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton_DUsuario_Cerrar;
    private javax.swing.JButton jButton_DUsuario_Grabar;
    private javax.swing.JButton jButton_DUsuario_Imprimir;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabel_CodSocio;
    private javax.swing.JLabel jLabel_nombreSocio;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JTextField jText_DUsuario_ComunZona;
    private javax.swing.JTextField jText_DUsuario_CorreoElect;
    private javax.swing.JTextField jText_DUsuario_Departam;
    private javax.swing.JTextField jText_DUsuario_Direccion;
    private javax.swing.JTextField jText_DUsuario_Provincia;
    private javax.swing.JTextField jText_DUsuario_RefUbicacion;
    private javax.swing.JTextField jText_DUsuario_Telefono;
    // End of variables declaration//GEN-END:variables
}
